package com.datatest.riskcheck.service.serviceImpl;

import com.datatest.beans.vo.SendEmailMessageVO;
import com.datatest.riskcheck.service.api.SendEmail;
import com.datatest.riskcheck.tools.EmailUtil;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Properties;
import static com.datatest.riskcheck.tools.EmailUtil.setSMTP;

/**
 * @Author lxt
 * Created by Jccfc on 2021/12/2.
 */
@EnableScheduling
@Service
public class SendEmailImpl implements SendEmail {

    @Override
    @Scheduled(cron = "0 32 17 * * ?")
    public void sendEmail() throws Exception {
        EmailUtil dd = new EmailUtil("lxt@jccfc.com","85250195Star");
        Properties p = setSMTP("smtp.exmail.qq.com", "25", false, false);
        String subject = "下班提醒";
        String context = "下班了，请记得打卡哦，机会只有一次，错过打卡，两眼泪汪汪";
        String[] id = new String[]{"luolan@jccfc.com","wangp@jccfc.com","hush@jccfc.com","wenyang@jccfc.com"};
        SendEmailMessageVO vo = new SendEmailMessageVO(id, subject, context);
        vo.setCcAddress("lxt@jccfc.com");
        vo.setFormAddress("lxt@jccfc.com");
        vo.setContextType("text/html;charset=UTF-8");
        dd.sendMail2(p,vo);
    }

    @Scheduled(cron = "0 33 17 * * ?")
    public void sendEmail2() throws Exception {
        EmailUtil dd = new EmailUtil("lxt@jccfc.com","85250195Star");
        Properties p = setSMTP("smtp.exmail.qq.com", "25", false, false);
        String subject = "下班提醒";
        String context = "下班了，请记得打卡哦，机会只有一次，错过打卡，两眼泪汪汪";
        String[] id = new String[]{"wenyang@jccfc.com"};
        SendEmailMessageVO vo = new SendEmailMessageVO(id, subject, context);
        vo.setCcAddress("lxt@jccfc.com");
        vo.setFormAddress("lxt@jccfc.com");
        vo.setContextType("text/html;charset=UTF-8");
        dd.sendMail2(p,vo);
    }
}
